int fun(int w) {
    int base = 1;
    while (w / base >= 10) {
        base *= 10;
    }
    return w % base;
}
